﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PurchaseOutAdd.aspx.cs" Inherits="FJERP.PurchaseOutAdd" %>


<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
        <head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <script type="text/javascript" src="lib/PIE_IE678.js"></script>
    <![endif]-->
    <link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <script src="lib/jquery/1.9.1/jquery.min.js"></script>
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>添加管理员</title>
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal" runat="server">
        <div>
            <label><span class="c-red">*</span>供应商名称：</label>
            <asp:DropDownList ID="DropDownList1" runat="server" Width="200px" class="input-text"></asp:DropDownList>
            <label><span class="c-red">&nbsp; *</span>出货仓库：</label>
            <asp:DropDownList ID="DropDownList2" runat="server" Width="200px" class="input-text"></asp:DropDownList>
                   </div>       <div>
             <label><span class="c-red">&nbsp; *</span>  退货日期：</label>
          <input type="text"  id="logmin" style="width:200px;" class="input-text"><label><span class="c-red">&nbsp;&nbsp;&nbsp;&nbsp; *</span>  经办人：</label>
            <asp:DropDownList ID="DropDownList3" runat="server" Width="200px" class="input-text"></asp:DropDownList>
        </div>
        <div> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" class="input-text"  id="Product_Modelspe" style="width:200px;"><input id="Button1" type="button" value="搜索"  onclick="fun()" style="border-radius:15px;width:100px;background-color:#00ff21"/><input id="Button3" type="button" value="清空"  onclick="    fun2()" style="border-radius:15px;width:100px;background-color:#00ff21"/></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="Button2" type="button" value="确认"  onclick="    check()" style="width:200px;height:25px;border-radius:15px;background-color:#2bd4ab"/></div>
        	<table class="table table-border table-bordered table-bg table-hover table-sort" id="psser">
			<thead>
				<tr class="text-c">
				<th>商品名称</th>
				<th>规格型号</th>
				<th>进价</th>
				<th>商品类别</th>
                <th>生产厂商</th>
                <th>数量</th>
                <th>总金额</th>
                <th>操作</th>
				</tr>
			</thead>
			<tbody>
				
			</tbody>
		</table>
        </form>
    
</article>

<!--_footer 作为公共模版分离出去--> 
   <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>
    <script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script>
    <script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="js/H-ui.js"></script>
    <script type="text/javascript" src="js/H-ui.admin.js"></script>
<!--/_footer /作为公共模版分离出去--> 

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-add").validate({
		rules:{
			adminName:{
				required:true,
				minlength:4,
				maxlength:16
			},
			password:{
				required:true,
			},
			password2:{
				required:true,
				equalTo: "#password"
			},
			sex:{
				required:true,
			},
			phone:{
				required:true,
				isPhone:true,
			},
			email:{
				required:true,
				email:true,
			},
			adminRole:{
				required:true,
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit();
			var index = parent.layer.getFrameIndex(window.name);
			parent.$('.btn-refresh').click();
			parent.layer.close(index);
		}
	});
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
    <script>
        function fun() {
            var ss = $("#Product_Modelspe").val();
            alert(ss);
            $.ajax({
                type: "post",
                url: "Handler/Purcachase.ashx",
                data: {
                    action: "Out_Show",
                    Product_Modelspe:ss,
                },
                success: function (data1) {
                    var data = eval(data1);
                    for (var i in data) {
                        var pp = "<tr class='text-c'><td>" + data[i].Product_Name + "</td><td>" + data[i].Product_Modelspe + "</td><td  id='price" + data[i].Product_Id + "'>" + data[i].Product_Price + "</td><td>" + data[i].Product_Type_Name + "</td><td>" + data[i].Product_frim + "</td><td><input class='input-text' id='num" + data[i].Product_Id + "' type='text'  style='width:200px;' onchange='fun1(" + data[i].Product_Id + ")' /></td><td><span id='SumMoney" + data[i].Product_Id + "'>0</span></td></tr>";
                                $(".table tbody").append(pp);
                    }
                }
            })
        }
        function fun1(id)
        {
            var num = $("#num" + id + "").val();
            var price = $("#price" + id + "").html();
            alert(price);
            var sum = num * price;
            $("#SumMoney" + id + "").html(sum);
        }
        function check() {
            //$(":checkbox").each(function () {
            //    if ($(this).attr("checked") == "checked") {
            //        var por=$(this).val();
            //    }
            //});
            //var num = "";
            //var SumMoney = "";
            //var selectvalue = "";
            //var emplist = $("[name='ck']:checked");
            //$(emplist).each(function (index, item) {
            //    ss = $(item).val();
            //    num += $("#num" + ss + "").val() + ",";
            //    SumMoney += $("#SumMoney" + ss + "").html() + ",";
            //    if(selectvalue.length>0)
            //    {
            //        selectvalue += ",";
            //    }
            //    selectvalue += $(item).val();
            //})
            //num = num.substr(0, num.length - 1);
            //SumMoney = SumMoney.substr(0, SumMoney.length - 1);
            ////alert(selectvalue);
            //alert(num);
            var Supplier_Id = $("#DropDownList1 option:selected").val();
            var WareHose_Id = $("#DropDownList2 option:selected").val();
            var Employee_Id = $("#DropDownList3 option:selected").val();
            var Product_Id = new Array();
            var i = -1;
            $("[name='ck']").each(function () {
                i++;
                Product_Id[i] = $(this).val();

            })
            var PurchaseMate_Num = new Array();
            var p = -1;
            $("[name='num']").each(function () {
                p++;
                PurchaseMate_Num[p] = $(this).val();
            })

            var PurchaseMate_Price = new Array();
            var r = -1;
            $("[name='SumMoney']").each(function () {
                r++;
                PurchaseMate_Price[r] = $(this).html();

            })
            //字符拼接XML;
            var xml = "<mm>"
            for (var i = 0; i < $("[name='num']").length; i++) {
                xml += "<xx Product_Id='" + Product_Id[i] + "' PurchaseMate_Num='" + PurchaseMate_Num[i] + "' PurchaseMate_Price='" + PurchaseMate_Price[i] + "' />";

            }
            xml += "</mm>"
            var encodexml = encodeURIComponent(xml);
            var sumM = 0;
            $("[name='SumMoney']").each(function () {

                sumM += parseInt($(this).html());
            })
            $.ajax({
                type: "post",
                url: "Handler/Purcachase.ashx",
                data: {
                    sumM: sumM,
                    Supplier_Id: Supplier_Id,
                    WareHose_Id: WareHose_Id,
                    Employee_Id: Employee_Id,
                    Purchase_Remark: $("#Purchase_Remark").val(),
                    xml: encodexml
                },
                success: function (data) {
                    if (data > 0) {
                        alert("OK");
                    }
                    else {
                        alert("No");
                    }

                },
                error: function () {

                    alert("Game over")
                }
            })

        }
        function fun2() {
            $(".table tbody").empty("");
        }
    </script>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
    {"appName":"Firefox","requestId":"21939549b88f43619824263d11962455"}
</script>
<script type="text/javascript" src="http://localhost:26516/b63ee82e3f23478e87ae72d60666dcd2/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>
